﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPatternStudy.Creations.Singletons
{
    class DoubleCheckSingleton
    {
        private static readonly Object _lock = new Object();
        private static DoubleCheckSingleton _instance;

        private DoubleCheckSingleton() { }

        public static DoubleCheckSingleton Singleton
        {
            get
            {
                if (_instance != null)
                {
                    return _instance;
                }

                lock (_lock)
                {
                    if (_instance == null)
                    {
                        _instance = new DoubleCheckSingleton();
                    }
                }

                return _instance;
            }
        }
    }
}
